<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Send mSQL query</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.msql-pconnect.html">msql_pconnect</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.msql-regcase.html">msql_regcase</a></div>
 <div class="up"><a href="ref.msql.html">mSQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.msql-query" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">msql_query</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">msql_query</span> &mdash; <span class="dc-title">Send mSQL query</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.msql-query-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>msql_query</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$query</code></span>
   [, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   <span class="function"><strong>msql_query()</strong></span> sends a query to the currently active 
   database on the server that&#039;s associated with the specified link 
   identifier.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.msql-query-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">query</code></em></dt>

     <dd>

      <p class="para">
       The SQL query.
      </p>
     </dd>

    
    <dt>
<em><code class="parameter">
link_identifier</code></em></dt>
<dd>
<p class="para">mSQL 连接。如果不指定，则使用由
<span class="function"><a href="function.msql-connect.html" class="function">msql_connect()</a></span> 最近打开的连接。如果没有找到该连接，函数会尝试通过调用
<span class="function"><a href="function.msql-connect.html" class="function">msql_connect()</a></span> 建立连接并使用它。
</p></dd>

   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.msql-query-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a positive mSQL query identifier on success, or <strong><code>FALSE</code></strong> on
   error.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.msql-query-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1490">
    <p><strong>Example #1 <span class="function"><strong>msql_query()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php&nbsp;<br />$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">msql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbserver"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"unable&nbsp;to&nbsp;connect&nbsp;to&nbsp;msql&nbsp;server:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">msql_error</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">msql_select_db</span><span style="color: #007700">(</span><span style="color: #DD0000">"db"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$link</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"unable&nbsp;to&nbsp;select&nbsp;database&nbsp;'db':&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">msql_error</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">msql_query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;*&nbsp;FROM&nbsp;table&nbsp;WHERE&nbsp;id=1"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">"query&nbsp;failed:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">msql_error</span><span style="color: #007700">());<br />}<br /><br />while&nbsp;(</span><span style="color: #0000BB">$row&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">msql_fetch_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">"id"</span><span style="color: #007700">];<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.msql-query-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.msql-db-query.html" class="function" rel="rdfs-seeAlso">msql_db_query()</a> - Send mSQL query</span></li>
    <li class="member"><span class="function"><a href="function.msql-select-db.html" class="function" rel="rdfs-seeAlso">msql_select_db()</a> - Select mSQL database</span></li>
    <li class="member"><span class="function"><a href="function.msql-connect.html" class="function" rel="rdfs-seeAlso">msql_connect()</a> - Open mSQL connection</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.msql-pconnect.html">msql_pconnect</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.msql-regcase.html">msql_regcase</a></div>
 <div class="up"><a href="ref.msql.html">mSQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
